
const cd = ['104.06','30.67','成都']
const xm = ['118.08','24.48','厦门']
const qz = ['118.68','24.87','泉州']
const fz = ['119.30','26.08','福州']
const citys =[cd,xm,qz,fz]
const minDistance = {

}

export function solve() {
  let minDistance = ''
  let arr = []
  let storageValue = localStorage.getItem('curCity')
  if(!storageValue){
    return '厦门'
  }
  let curCity = storageValue.split('省')[1].replace('市', '')
  citys.forEach(function (it) {
    if(curCity == it[2]){
      arr.push(0)
    }else {
      const lng = localStorage.getItem('lng')
      const lat = localStorage.getItem('lat')
      let distance = Math.pow(it[0]-lng , 2) + Math.pow(it[1]-lat , 2)
      arr.push(distance)
    }


  })
  minDistance = Math.min.apply(null,arr)
  let index = arr.indexOf(minDistance)
  let latest = citys[index][2]
  return latest
}
